# Maintainer: Jeff Hubbard <musikernel@gmail.com>

_realname=vamp-plugin-sdk
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.9.0
pkgrel=1
pkgdesc="Vamp plugins extract descriptive information from audio data (mingw-w64)"
arch=('any')
url="https://www.vamp-plugins.org/"
license=("BSD")
options=('!buildflags')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-libsndfile")
source=("https://code.soundsoftware.ac.uk/attachments/download/2588/vamp-plugin-sdk-${pkgver}.tar.gz"
        01-mingw-shared.patch)
sha256sums=('b72a78ef8ff8a927dc2ed7e66ecf4c62d23268a5d74d02da25be2b8d00341099'
            '64201d3cf3ef1e2d56a6079eb3938b353983a5b2e8d63a41ab7419a71257f64a')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/01-mingw-shared.patch
}

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  cp -rf "${_realname}-${pkgver}" "build-${MINGW_CHOST}"
  cd build-${MINGW_CHOST}

  CFLAGS+=" -D_USE_MATH_DEFINES"
  CPPFLAGS+=" -D_USE_MATH_DEFINES"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
}
